#ifndef __BOW_BLOCK_H__
#define __BOW_BLOCK_H__

#include "Block.hpp"
#include "ArrowBlock.h"

namespace PocketSurvival
{
    // 弓
    class BowBlock : public Block
    {
    public:
        static constexpr int32_t Index()
        {
            return 191;
        }
        virtual int32_t getIndex() override; 
        virtual const std::string &getBlockName() override;
        virtual int32_t getDamage(int32_t value) override;
        virtual int32_t setDamage(int32_t value, int32_t damage) override;

		static inline ArrowType GetArrowType(int32_t data);
		static inline int32_t SetArrowType(int32_t data, ArrowType arrowType);
		static inline int32_t GetDraw(int32_t data);
		static inline int32_t SetDraw(int32_t data, int32_t draw);
    };

	inline ArrowType BowBlock::GetArrowType(int32_t data)
	{
		int32_t num = (data >> 4) & 0xF;
		return (ArrowType)num;
	}

	inline int32_t BowBlock::SetArrowType(int32_t data, ArrowType arrowType)
	{
		int32_t num = (int32_t)(arrowType);
		return (data & -241) | ((num & 0xF) << 4);
	}

	inline int32_t BowBlock::GetDraw(int32_t data)
	{
		return data & 0xF;
	}

	inline int32_t BowBlock::SetDraw(int32_t data, int32_t draw)
	{
		return (data & -16) | (draw & 0xF);
	}

} // namespace PocketSurvival


#endif
